# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import json


class PatencentPipeline(object):
    def open_spider(self, spider):
        self.file = open(r"ten.json", "w")

    def process_item(self, item, spider):
        content = json.dumps(dict(item), ensure_ascii=False) + '\n'
        # print(content)
        f=open(r"ten3.json", "a")
        f.writelines(content)
        f.close()
        self.file.write(content)
        return item

    def close_spider(self, spider):
        print("===============")
        self.file.close()
